import { UserProfilesAPI } from '@/request/api'
export default {
    namespaced: true,
    state: {
        //是否显示登录模态框
        userinfo: {
            nickName: "昵称",
            coin: "--",
            headImg: require("../../assets/img/service.848ec511.png")
        },
        cartTotal: 88
    },
    mutations: {
        //修改是否显示模态框的数据
        changeUserinfo(state, payload) {
            // console.log(1);
            state.userinfo = payload.userInfo,
             state.cartTotal = payload.cartTotal
        },
        initUserinfo(state) {
            state.userinfo = {
                nickName: "昵称",
                coin: "--",
                headImg: require("../../assets/img/service.848ec511.png")
            }
            state.cartTotal = "";
        }
    },
    actions: {
        async asyncChangeUserinfo({ commit }) {
            let res = await UserProfilesAPI();
            console.log("用户信息", res);
            commit("changeUserinfo", res.data)
        }
    }
}